<?php
if (!defined('ROOT_PATH')) die('No direct access.');
function view_barang($id){
	view_header_top();
	$barang = getBarang($id);
	$user = getUserId($barang['idPenjual']);
	//----------------------------------------------------------------
	$title = "Realita - ".$barang['nama'];
	$content = "Realita - ".$barang['nama'];
	$url = BARANG_URL."a/".$barang['idBarang']."/".$barang['slug-nama'];
	$image = IMAGE_URL."300x240.gif";	//barangnya
	$desc = "Deskripsi barang : ".$barang['deskripsi'];
	$auth = "RealiTA";
	$qwords = "toko, marketplace, umkm, ".$user['nama'].", ".$user['nama-toko'].", ".$barang['nama'];
	//----------------------
	echo "<title>$title</title>";
	//<!--META DATA Open Graph-->
	echo "<meta property=\"og:title\" content=\"$title\"/>";
	echo "<meta property=\"og:type\" content=\"$content\"/>";
	echo "<meta property=\"og:url\" content=\"$url\"/>";
	echo "<meta property=\"og:image\" content=\"$image\"/>";
	echo "<meta property=\"og:site_name\" content=\"RealiTA UMKM\"/>";
	echo "<meta property=\"og:description\" content=\"$desc\" />";
	//<!--META DATA FB-->
	echo "<meta property=\"fb:app_id\" content=\"147346958657510\" />";
	//<!--META DATA-->
	echo "<meta name=\"author\" content=\"$auth\" />";
	echo "<meta name=\"keywords\" content=\"$qwords\" />";
	echo "<meta name=\"description\" content=\"$desc\" />";
	echo "<meta name=\"robots\" content=\"ALL\" />";
	echo "<meta charset=\"UTF-8\" />";
	//----------------------------------------------------------------
	view_header_bottom();
?>
<!-- Content -->
    <ul class="breadcrumbs">
	  <li><a href="<? echo HOME_URL ?>">Beranda</a></li>
	  <li><a href="<? echo MARKETPLACE_URL ?>">Marketplace</a></li>
	  <li><a href="<? echo TOKO_URL."a/".$user['idFB']."/".$user['slug_nama-toko'] ?>"><?php echo $user['nama-toko'] ?></a></li>
	  <li class="current"><a href="<? echo BARANG_URL."a/".$barang['idBarang']."/".$barang['slug-nama']; ?>"><?php echo $barang['nama'] ?></a></li>
	</ul>
	<div class="row">    
		<!-- Main Content Section -->
		<!-- This has been source ordered to come first in the markup (and on small devices) but to be to the right of the nav on larger screens -->
		<div class="large-9 push-3 columns">		  
		  <h3><?php echo $barang['nama'] ?></h3>
			<?php
			if (isset($_SESSION['status-tambah'])) {
				echo "<div class='alert-box success'>".$_SESSION['status-tambah']."<a href='#' class='close'>&times;</a></div>";
				unset($_SESSION['status-tambah']);
			}
			?>
		  <p><?php echo $barang['deskripsi'] ?></p>
          <div class="row">
			<?php for ($i=1; $i<=3; $i++){ ?>
            <div class="large-4 small-6 columns">
              <img src="<? echo IMAGE_URL ?>1000x1000.gif">
            </div>
            <?php } ?>
          </div>
          <hr />
          <div class="row">
			<div class="large-4 small-6 columns">
              Teman yang sudah membeli
            </div>
		  </div>
		  <hr />
          <div class="row">
			<div class="large-4 small-6 columns">
              <h5>Review</h5>
              <?php
				if (isset($_SESSION['logged'])){
					echo "<a href=\"".BLOG_URL."buat/$id/barang\">[Buat Review]</a><br /><br />";
				}
				$articles = getArtikelnya($barang['idBarang']);
				foreach ($articles as $article){
					 echo "<a href=\"".BLOG_URL."a/".$article['idArtikel']."/".$article['slug-judul']."\">".$article['judul']."</a><br /><br />";
				}
			?>
            </div>
		  </div>
		  <hr />
          <div class="row">
			<div class="large-4 small-6 columns">
              FB Comment Plugin
            </div>
		  </div>
		</div>
		<!-- Nav Sidebar -->
		<!-- This is source ordered to be pulled to the left on larger screens -->
		<div class="large-3 pull-9 columns">
		  <ul class="side-nav">
			<li>
				<div class="large-10 columns">
					<p><img src="<? echo IMAGE_URL ?>320x240.gif" /></p>
					<h3><?php echo int_to_rp($barang['harga']) ?></h3>
					<form method="get" action="<?php echo KERANJANG_URL."beli" ?>">
						<input type="hidden" value="<?php echo $barang['idBarang'] ?>" name="id" />
						<div class="row collapse">
							<div class="large-9 columns">
								<span class="prefix">Gambar keranjang</span>
							</div>
							<div class="large-3 columns">
								<input type="text" placeholder="0" name="qty">
							</div>
						</div>
						<div class="row">
							<div class="large-2 columns">
								<input class="small button" type="submit" value="Beli" name="beli" />
							</div>
						</div>
					</form>
				</div>
			</li>
			<hr />
			<?php
			  $pembeli = 1;
			  if (cekSdhBeli($pembeli,$user['idFB'])){
				  echo "<li>Beri rating</li>";
			  }
			  echo "<li>Nilai rating</li>";
			  ?>
			<li>Level Barang</li>
			<li><?php echo "<a href=\"".MARKETPLACE_URL.getMarket($barang['kategori'])."\">".getKategori($barang['kategori'])."</a>"; ?></li>
			<li>
				Tag : <?php echo $barang['keywords']?>
			</li>
			<hr />
			<li>FB Like</li>
			<li>FB Share</li>
			<li>Twit Share</li>
			<hr />
		  </ul>
		</div>
	  </div>
    <!-- End Content -->
<?php
	view_footer();
}
?>
